Image defect identification

ABSTRACT

A method, a device and a computer program product for image processing are proposed. In the method, whether a first image indicates a defect associated with a target object is determined. In response to determining that the first image indicates the defect, a second image absent from the defect is obtained based on the first image. The defect is identified by comparing the first image with the second image. In this way, the defect associated with the target object in the image can be accurately and efficiently identified or segmented.

BACKGROUND

The present invention relates to image processing, and morespecifically, to a method, a device and a computer program product foridentifying a defect associated with a target object in an image.

Nowadays, there exists high demand on automated and accurate defectsegmentation in manufactory industry. The demand on automated visualinspection technologies for the defect segmentation is increasinglygrowing across the manufactory industry in areas such as manualinspection of smartphone part assembling, component-level defectinspection on Printed Circuit Board (PCB) (more than 20 defect types),and Liquid Crystal Display (LCD) panel defect detection (more than 120defect types).

Accurate defect segmentation is of significant value for determining thedefect severity and the subsequent processing flow (for example, repair,rework, ignore, disposal, etc.). Due to the large amount of workloadrequired, the inspector is more willing to perform the annotation of thedefect in an image level (for example, annotate each image with a defecttype label), rather than precisely determining the defect location orperforming the annotation in a pixel-wise level.

SUMMARY

According to one embodiment of the present invention, there is provideda method for image processing. In the method, whether a first imageindicates a defect associated with a target object is determined. Inresponse to determining that the first image indicates the defect, asecond image absent from the defect is obtained based on the firstimage. The defect is identified by comparing the first image with thesecond image.

According to another embodiment of the present invention, there isprovided a device for image processing. The device comprises aprocessing unit and a memory coupled to the processing unit and storinginstructions thereon. The instructions, when executed by the processingunit, performing acts including: determining whether a first imageindicates a defect associated with a target object; in response todetermining that the first image indicates the defect, obtaining asecond image absent from the defect based on the first image; andidentifying the defect by comparing the first image with the secondimage.

According to yet another embodiment of the present invention, there isprovided a computer program product being tangibly stored on anon-transient machine-readable medium and comprising machine-executableinstructions. The instructions, when executed on a device, cause thedevice to perform acts including: determining whether a first imageindicates a defect associated with a target object; in response todetermining that the first image indicates the defect, obtaining asecond image absent from the defect based on the first image; andidentifying the defect by comparing the first image with the secondimage.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

Through the more detailed description of some embodiments of the presentdisclosure in the accompanying drawings, the above and other objects,features and advantages of the present disclosure will become moreapparent, wherein the same reference generally refers to the samecomponents in the embodiments of the present disclosure.

FIG. 1 depicts a cloud computing node according to an embodiment of thepresent invention.

FIG. 2 depicts a cloud computing environment according to an embodimentof the present invention.

FIG. 3 depicts abstraction model layers according to an embodiment ofthe present invention.

FIG. 4 shows a flow chart of an example method for image processingaccording to an embodiment of the present invention.

FIG. 5 shows a schematic diagram of an example defect segmentationaccording to an embodiment of the present invention.

FIG. 6 shows a schematic diagram of another example defect segmentationaccording to an embodiment of the present invention.

FIG. 7 shows a schematic diagram of yet another example defectsegmentation according to an embodiment of the present invention.

DETAILED DESCRIPTION

Some embodiments will be described in more detail with reference to theaccompanying drawings, in which the embodiments of the presentdisclosure have been illustrated. However, the present disclosure can beimplemented in various manners, and thus should not be construed to belimited to the embodiments disclosed herein.

It is to be understood that although this disclosure includes a detaileddescription on cloud computing, implementation of the teachings recitedherein are not limited to a cloud computing environment. Rather,embodiments of the present invention are capable of being implemented inconjunction with any other type of computing environment now known orlater developed.

Cloud computing is a model of service delivery for enabling convenient,on-demand network access to a shared pool of configurable computingresources (e.g. networks, network bandwidth, servers, processing,memory, storage, applications, virtual machines, and services) that canbe rapidly provisioned and released with minimal management effort orinteraction with a provider of the service. This cloud model may includeat least five characteristics, at least three service models, and atleast four deployment models.

Characteristics are as follows:

On-demand self-service: a cloud consumer can unilaterally provisioncomputing capabilities, such as server time and network storage, asneeded automatically without requiring human interaction with theservice's provider.

Broad network access: capabilities are available over a network andaccessed through standard mechanisms that promote use by heterogeneousthin or thick client platforms (e.g., mobile phones, laptops, and PDAs).

Resource pooling: the provider's computing resources are pooled to servemultiple consumers using a multi-tenant model, with different physicaland virtual resources dynamically assigned and reassigned according todemand. There is a sense of location independence in that the consumergenerally has no control or knowledge over the exact location of theprovided resources but may be able to specify location at a higher levelof abstraction (e.g., country, state, or datacenter).

Rapid elasticity: capabilities can be rapidly and elasticallyprovisioned, in some cases automatically, to quickly scale out andrapidly released to quickly scale in. To the consumer, the capabilitiesavailable for provisioning often appear to be unlimited and can bepurchased in any quantity at any time.

Measured service: cloud systems automatically control and optimizeresource use by leveraging a metering capability at some level ofabstraction appropriate to the type of service (e.g., storage,processing, bandwidth, and active user accounts). Resource usage can bemonitored, controlled, and reported providing transparency for both theprovider and consumer of the utilized service.

Service Models are as follows:

Software as a Service (SaaS): the capability provided to the consumer isto use the provider's applications running on a cloud infrastructure.The applications are accessible from various client devices through athin client interface such as a web browser (e.g., web-based e-mail).The consumer does not manage or control the underlying cloudinfrastructure including network, servers, operating systems, storage,or even individual application capabilities, with the possible exceptionof limited user-specific application configuration settings.

Platform as a Service (PaaS): the capability provided to the consumer isto deploy onto the cloud infrastructure consumer-created or acquiredapplications created using programming languages and tools supported bythe provider. The consumer does not manage or control the underlyingcloud infrastructure including networks, servers, operating systems, orstorage, but has control over the deployed applications and possiblyapplication hosting environment configurations.

Infrastructure as a Service (IaaS): the capability provided to theconsumer is to provision processing, storage, networks, and otherfundamental computing resources where the consumer is able to deploy andrun arbitrary software, which can include operating systems andapplications. The consumer does not manage or control the underlyingcloud infrastructure but has control over operating systems, storage,deployed applications, and possibly limited control of select networkingcomponents (e.g., host firewalls).

Deployment Models are as follows:

Private cloud: the cloud infrastructure is operated solely for anorganization. It may be managed by the organization or a third party andmay exist on-premises or off-premises.

Community cloud: the cloud infrastructure is shared by severalorganizations and supports a specific community that has shared concerns(e.g., mission, security requirements, policy, and complianceconsiderations). It may be managed by the organizations or a third partyand may exist on-premises or off-premises.

Public cloud: the cloud infrastructure is made available to the generalpublic or a large industry group and is owned by an organization sellingcloud services.

Hybrid cloud: the cloud infrastructure is a composition of two or moreclouds (private, community, or public) that remain unique entities butare bound together by standardized or proprietary technology thatenables data and application portability (e.g., cloud bursting forload-balancing between clouds).

A cloud computing environment is service oriented with a focus onstatelessness, low coupling, modularity, and semantic interoperability.At the heart of cloud computing is an infrastructure that includes anetwork of interconnected nodes.

Referring now to FIG. 1, a schematic of an example of a cloud computingnode is shown. Cloud computing node 10 is only one example of a suitablecloud computing node and is not intended to suggest any limitation as tothe scope of use or functionality of embodiments of the inventiondescribed herein. Regardless, cloud computing node 10 is capable ofbeing implemented and/or performing any of the functionality set forthhereinabove.

In cloud computing node 10 there is a computer system/server 12 or aportable electronic device such as a communication device, which isoperational with numerous other general purpose or special purposecomputing system environments or configurations. Examples of well-knowncomputing systems, environments, and/or configurations that may besuitable for use with computer system/server 12 include, but are notlimited to, personal computer systems, server computer systems, thinclients, thick clients, hand-held or laptop devices, multiprocessorsystems, microprocessor-based systems, set top boxes, programmableconsumer electronics, network PCs, minicomputer systems, mainframecomputer systems, and distributed cloud computing environments thatinclude any of the above systems or devices, and the like.

Computer system/server 12 may be described in the general context ofcomputer system-executable instructions, such as program modules, beingexecuted by a computer system. Generally, program modules may includeroutines, programs, objects, components, logic, data structures, and soon that perform particular tasks or implement particular abstract datatypes. Computer system/server 12 may be practiced in distributed cloudcomputing environments where tasks are performed by remote processingdevices that are linked through a communications network. In adistributed cloud computing environment, program modules may be locatedin both local and remote computer system storage media including memorystorage devices.

As shown in FIG. 1, computer system/server 12 in cloud computing node 10is shown in the form of a general-purpose computing device. Thecomponents of computer system/server 12 may include, but are not limitedto, one or more processors or processing units 16, a system memory 28,and a bus 18 that couples various system components including systemmemory 28 to processor 16.

Bus 18 represents one or more of any of several types of bus structures,including a memory bus or memory controller, a peripheral bus, anaccelerated graphics port, and a processor or local bus using any of avariety of bus architectures. By way of example, and not limitation,such architectures include Industry Standard Architecture (ISA) bus,Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, VideoElectronics Standards Association (VESA) local bus, and PeripheralComponent Interconnect (PCI) bus.

Computer system/server 12 typically includes a variety of computersystem readable media. Such media may be any available media that isaccessible by computer system/server 12, and it includes both volatileand non-volatile media, removable and non-removable media.

System memory 28 can include computer system readable media in the formof volatile memory, such as random access memory (RAM) 30 and/or cachememory 32. Computer system/server 12 may further include otherremovable/non-removable, volatile/non-volatile computer system storagemedia. By way of example only, storage system 34 can be provided forreading from and writing to a non-removable, non-volatile magnetic media(not shown and typically called a “hard drive”). Although not shown, amagnetic disk drive for reading from and writing to a removable,non-volatile magnetic disk (e.g., a “floppy disk”), and an optical diskdrive for reading from or writing to a removable, non-volatile opticaldisk such as a CD-ROM, DVD-ROM or other optical media can be provided.In such instances, each can be connected to bus 18 by one or more datamedia interfaces. As will be further depicted and described below,memory 28 may include at least one program product having a set (e.g.,at least one) of program modules that are configured to carry out thefunctions of embodiments of the invention.

Program/utility 40, having a set (at least one) of program modules 42,may be stored in memory 28 by way of example, and not limitation, aswell as an operating system, one or more application programs, otherprogram modules, and program data. Each of the operating system, one ormore application programs, other program modules, and program data orsome combination thereof, may include an implementation of a networkingenvironment. Program modules 42 generally carry out the functions and/ormethodologies of embodiments of the invention as described herein.

Computer system/server 12 may also communicate with one or more externaldevices 14 such as a keyboard, a pointing device, a display 24, etc.;one or more devices that enable a user to interact with computersystem/server 12; and/or any devices (e.g., network card, modem, etc.)that enable computer system/server 12 to communicate with one or moreother computing devices. Such communication can occur via Input/Output(I/O) interfaces 22. Still yet, computer system/server 12 cancommunicate with one or more networks such as a local area network(LAN), a general wide area network (WAN), and/or a public network (e.g.,the Internet) via network adapter 20. As depicted, network adapter 20communicates with the other components of computer system/server 12 viabus 18. It should be understood that although not shown, other hardwareand/or software components could be used in conjunction with computersystem/server 12. Examples, include, but are not limited to: microcode,device drivers, redundant processing units, external disk drive arrays,RAID systems, tape drives, and data archival storage systems, etc.

Referring now to FIG. 2, illustrative cloud computing environment 50 isdepicted. As shown, cloud computing environment 50 includes one or morecloud computing nodes 10 with which local computing devices used bycloud consumers, such as, for example, personal digital assistant (PDA)or cellular telephone 54A, desktop computer 54B, laptop computer 54C,and/or automobile computer system 54N may communicate. Nodes 10 maycommunicate with one another. They may be grouped (not shown) physicallyor virtually, in one or more networks, such as Private, Community,Public, or Hybrid clouds as described hereinabove, or a combinationthereof. This allows cloud computing environment 50 to offerinfrastructure, platforms and/or software as services for which a cloudconsumer does not need to maintain resources on a local computingdevice. It is understood that the types of computing devices 54A-N shownin FIG. 2 are intended to be illustrative only and that computing nodes10 and cloud computing environment 50 can communicate with any type ofcomputerized device over any type of network and/or network addressableconnection (e.g., using a web browser).

Referring now to FIG. 3, a set of functional abstraction layers providedby cloud computing environment 50 (FIG. 2) is shown. It should beunderstood in advance that the components, layers, and functions shownin FIG. 3 are intended to be illustrative only and embodiments of theinvention are not limited thereto. As depicted, the following layers andcorresponding functions are provided:

Hardware and software layer 60 includes hardware and softwarecomponents. Examples of hardware components include: mainframes 61; RISC(Reduced Instruction Set Computer) architecture based servers 62;servers 63; blade servers 64; storage devices 65; and networks andnetworking components 66. In some embodiments, software componentsinclude network application server software 67 and database software 68.

Virtualization layer 70 provides an abstraction layer from which thefollowing examples of virtual entities may be provided: virtual servers71; virtual storage 72; virtual networks 73, including virtual privatenetworks; virtual applications and operating systems 74; and virtualclients 75.

In one example, management layer 80 may provide the functions describedbelow. Resource provisioning 81 provides dynamic procurement ofcomputing resources and other resources that are utilized to performtasks within the cloud computing environment. Metering and Pricing 82provide cost tracking as resources are utilized within the cloudcomputing environment, and billing or invoicing for consumption of theseresources. In one example, these resources may include applicationsoftware licenses. Security provides identity verification for cloudconsumers and tasks, as well as protection for data and other resources.User portal 83 provides access to the cloud computing environment forconsumers and system administrators. Service level management 84provides cloud computing resource allocation and management such thatrequired service levels are met. Service Level Agreement (SLA) planningand fulfillment 85 provide pre-arrangement for, and procurement of,cloud computing resources for which a future requirement is anticipatedin accordance with an SLA.

Workloads layer 90 provides examples of functionality for which thecloud computing environment may be utilized. Examples of workloads andfunctions which may be provided from this layer include: mapping andnavigation 91; software development and lifecycle management 92; virtualclassroom education delivery 93; data analytics processing 94;transaction processing 95; and image processing 96.

As discussed above, it is required that the defect segmentation can beperformed based on the weakly-supervised image level annotation.Traditionally, a Fully Convolutional Network (FCN) can be used for thesemantic segmentation. However, the FCN requires accurate objectpositioning in the granularity of pixel, and high labeling effort intraining data preparation.

In addition, an attention-based approach can be used for pixel-wiseclassification. In the attention-based approach, object segmentation istrained with image labels. A visualization method (such as a classactivation heatmap) from a pre-trained Convolutional Neural Network(CNN) classification model can be used to indicate which region in theimage is relevant to a class. However, the heatmap can only cover theobject of that class roughly. Moreover, only one or a few objects areindicated in the heatmap when numerous objects of the same class presentin the image.

In order to at least partially solve one or more of the above problemsand other potential problems, example embodiments of the presentdisclosure propose a solution for image processing.

Generally speaking, according to embodiments of the present disclosure,an image (referred to as “first image”) of a target object can beobtained. The first image can present a certain pattern or a periodicfeature, but not limited thereto. For example, the first image can bethe image of the LCD/PCB panel. The first image can then be applied toan image classifier for classifying an image to be normal or abnormal. Anormal image can represent an image of a target object that does notinclude a defect, and an abnormal image can represent an image of atarget object including at least one defect. For example, the defect maybe a dead pixel, a scratch, a bubble or the like in the LCD panel, orpoor soldering, missing component or the like of the PCB panel.

When a result of the classifying indicating that the first imageindicates a defect, a heatmap for locating the defect in the first imagecan be generated, and a mask covering at least a portion of the defectcan be generated based on the heatmap. Then, a recovered image can begenerated by removing at least a portion of the defect covered by themask from the first image. For example, the recovered image can begenerated by applying the image to be recovered with the mask to aGenerative Adversarial Network (GAN) based model trained to recover thedefect.

The recovered image can be applied to the image classifier. If a resultof the classifying indicates that the recovered image does not include adefect, that is to say, the recovered image is a fully recovered normalimage (referred to as “second image”), the defect in the first image canbe identified by comparing the first image with the second image.Otherwise, the recovered image will iteratively go through furtherrecovering process until a fully recovered normal image is obtained,such that the defect in the first image can be identified. It is to beunderstood that in the context of the present invention, identifying adefect in the image means that the defect segmentation is performed onthe image.

In this way, the defect associated with the target object can beautomatically and accurately segmented from the image. Since the imageclassification and recovering process of the defect segmentation isperformed on the image level, the defect segmentation can be used forthe weakly-supervised or image level annotation dataset. In this case,no pixel level segmentation label is required for training, causing asignificant saving of location labeling in traditional objectdetection/image segmentation tasks. In addition, the defect segmentationof the present invention is widely applicable. It is not limited to beapplied for images with rigid patterns or templates, and can be appliedfor images with various defect numbers or sizes. Further, the result ofthe defect segmentation can also be used as the segmentation annotation.Thus, the proposed solution increases the accuracy, efficiency andapplicability of the defect segmentation and improves the userexperience in defect inspection.

Now some example embodiments will be described with reference to FIGS.4-7. FIG. 4 shows a flow chart of an example method 400 for imageprocessing according to an embodiment of the present invention. Themethod 400 may be at least in part implemented by the computersystem/server 12, or other suitable systems. FIG. 5 shows a schematicdiagram of an example defect segmentation 500 according to an embodimentof the present invention. For purpose of discussion, the method 400 willbe described with respect to FIG. 5.

At 410, the computer system/server 12 determines whether a first imageindicates a defect associated with a target object. In some embodiments,the first image can present a certain pattern or a periodic feature. Forexample, the first image can be the image of the LCD/PCB panel. Anexample of the first image is shown as the image 510 in FIG. 5.

In some embodiments, the computer system/server 12 can obtain the firstimage, and apply the first image to an image classifier for classifyingan image to be normal or abnormal. A normal image can represent an imageof a target object that does not include a defect, and an abnormal imagecan represent an image of a target object including a defect. The imageclassifier can be any suitable image classifier, for example but notlimited to, a Binary Classifier model. Since the binary classifier modelis trained to identify whether an image is normal or abnormal, theweakly-supervised or image level annotation dataset is enough.

As an example, in the training stage of the image classifier, a largenumber of images can be applied to train the image classifier. Some ofimages can be labeled as normal images, and the other images can belabeled as abnormal images indicating a defect. No location informationregarding the defect needs to be provided. After the training process,the image classifier can achieve a high classification precision.

If a result of the classifying indicating that the first image isabnormal, the computer system/server 12 can determine that first imageindicates the defect. Otherwise, it is determined that the first imagedoes not indicate the defect.

At 420, if the first image indicates the defect, the computersystem/server 12 obtains a second image absent from the defect based onthe first image. An example of the second image is shown as the image540 in FIG. 5.

In some embodiments, to generate the second image, the computersystem/server 12 can generate a heatmap indicating heat values of pixelsin the first image. Specifically, the heatmap can be generated byapplying the first image to a class activation heatmap model beingtrained to locate the defect in the first image. Generally speaking, thehigher the heat value of a pixel is, the more likely the pixel relatesto the defect. In this case, the heatmap can locate the defect in thefirst image. An example of the heatmap is shown in the image 520 in FIG.5.

However, as shown in FIG. 5, the heatmap only coarsely locates thedefect in the first image. In this case, the computer system/server 12can generate, based on the heatmap, a mask covering at least a portionof the defect. An example of the mask is shown in the image 530 in FIG.5.

The mask usually can have a predetermined shape, such as a square shapeor rectangular shape, such that the mask can more precisely locate thedefect for removing the defect later. This is because the size of themask directly influences the defect removing or image recoveringperformance. Generally, a smaller mask can result in a betterperformance.

In some embodiments, the computer system/server 12 can determine heatvalues of a set pixels in the first image exceeding a predeterminedthreshold, and generate the mask covering the set of pixels. In thisway, the most suspicious defect region can be covered by the mask.

Then, the computer system/server 12 can generate the second image byremoving at least the portion of the defect covered by the mask from thefirst image. The defect can be removed by filling the pixels of themasked region in the image with plausible pixels. For example, thesecond image can be generated by applying the first image with the maskto a Generative Adversarial Network (GAN) based model being trained toremove at least the portion of the defect.

The purpose of the GAN based model is to generate a masked region whichlooks real and nature and resembles the unmasked original image. Toachieve this purpose, a large number of normal images can be used totrain the GAN based model. The training can be performed by randomlymasking a region in the normal images. The loss function of the GANbased model is the sum of the pixel-wise reconstruction loss and theadversarial discriminator loss. Visually, the GAN based model works formost cases, which leads to a satisfying segmentation result. Inaddition, since the GAN based model is trained from normal images, theGAN based model can be considered as weakly-supervised or evenunsupervised.

Besides the GAN based model, other image recovering techniques forremoving the defect can also be used, such as matching and copyingbackground patches to the masked region, or matching the masked regionfrom a database with image indexing, for example, by indexing acorresponding normal image in the database and copying the correspondingregion in the indexed image to the masked region.

In addition, since various defect number or size needs to be processed,in some embodiments, the defect cannot be removed at one time. Forexample, the first image may be an image of a target object with morethan one defect, or an image of a target object with a large defect. Inthese embodiments, the first image needs to be iteratively recovered toobtain the second image absent from the defect.

For example, to determine whether the recovered image generated from thefirst image is absent from the defect, the computer system/server 12 canobtain the recovered image (referred to as “intermediate image”) byremoving at least a portion of the defect from the first image. Thecomputer system/server 12 can determine whether the intermediate imageindicates the defect is completely removed from the intermediate image.If so, the computer system/server 12 can directly determine theintermediate image to be the second image.

Otherwise, if the defect is not completely removed from the intermediateimage, for example, a remaining portion of the defect is still presentin the intermediate image, the computer system/server 12 can remove theremaining portion of the defect from the intermediate image based on aheatmap of the intermediate image. Specifically, the computersystem/server 12 can generate the heatmap indicating heat values ofpixels in the intermediate image, and generate, based on the heatmap, amask covering at least a portion of the remaining defect. Then, thecomputer system/server 12 can generate a further image by removing atleast the portion of the remaining defect covered by the mask. Thecomputer system/server 12 can again determine whether the further imageindicates the defect is fully removed. In this way, the image recoveringprocess is repeated iteratively, until the second image absent from thedefect is obtained. Such iterative recovery can ensure the segmentationintegrity.

More detailed examples regarding an image of a target object with alarge defect, and an image of a target object with more than one defectare described with reference to FIGS. 6 and 7.

After obtaining the second image absent from the defect, the computersystem/server 12 can identify the defect by comparing the first imagewith the second image, at 430. In this way, the defect can be segmentedfrom the first image. For example, the computer system/server 12 can usea simple subtraction or mathematic morphology method to obtain thesegmentation result from the first image with the second image. Inaddition, the segmentation result can also be used as a segmentationannotation for further processing. As an example of the segmentationresult, the image 550 of FIG. 5 shows the segmented defect.

In this way, by combining the binary classifier model, the classactivation heatmap model, and the GAN based model, the defectsegmentation can be performed on the weakly-supervised or image levelannotation dataset. In addition, such defect segmentation is widelyapplicable, and can be used for various defect number or size. Thus, theproposed solution increases the accuracy, efficiency and applicabilityof the defect segmentation and improving the user experience in defectinspection.

FIG. 6 shows a schematic diagram of an example defect segmentation 600for an image including a large defect according to an embodiment of thepresent invention. The defect segmentation 600 may be at least in partimplemented by the computer system/server 12, or other suitable systems.

As shown in FIG. 6, the first image 610 includes a prolonged defectassociated with a target device. The computer system/server 12determines that the first image 610 indicates at least a defect. Next,the computer system/server 12 generates the heatmap 612 locating thedefect in the first image 610. It can be seen that only a portion of thedefect is emphasized in the heatmap 612. In this case, the computersystem/server 12 generates the mask 614 covering only the upper portionof defect. Then, the computer system/server 12 generates theintermediate image 720 by removing the upper portion of defect coveredby the mask 614.

However, the remaining portion of defect is not removed from theintermediate image 620, and the intermediate image 620 is not fullyrecovered. In this event, the computer system/server 12 determines thatthe intermediate image 620 indicates at least a defect, and performsanother iteration for removing the defect. That is to say, the computersystem/server 12 generates the heatmap 622 locating the remaining defectand the mask 624 covering the upper portion of the remaining defect.Then, the computer system/server 12 generates a further image byremoving the upper portion of the remaining defect covered by the mask624. The iteration for removing the defect repeats until the secondimage 630 exclude any defect is obtained.

The computer system/server 12 identifies or segments the defect bycomparing the first image 610 with the second image 630. The defectsegmentation result is shown in the image 640, which shows the segmentedprolonged defect. In this way, the defect with a large size or length inthe image can be precisely segmented by recovering the defective image,and comparing the original image with the recovered image.

FIG. 7 shows a schematic diagram of an example defect segmentation 700for an image including multiple defects according to an embodiment ofthe present invention. The defect segmentation 700 may be at least inpart implemented by the computer system/server 12, or other suitablesystems.

As shown in FIG. 7, the first image 710 includes two defects associatedwith a target device. The computer system/server 12 determines that thefirst image 710 indicates at least a defect. Next, the computersystem/server 12 generates the heatmap 712 locating the defects in thefirst image 710. Although the heatmap 712 locates both defects, thelower defect is emphasized in the heatmap 712. In this case, thecomputer system/server 12 generates the mask 714 covering only the lowerdefect. Then, the computer system/server 12 generates the intermediateimage 720 by removing the lower defect covered by the mask 714.

However, the upper defect is not removed from the intermediate image720, and the intermediate image 720 is not fully recovered. In thisevent, the computer system/server 12 determines that the intermediateimage 720 indicates at least a defect, and performs another iterationfor removing the defect. That is to say, the computer system/server 12generates the heatmap 722 locating the upper defect and the mask 724covering the upper defect. Then, the computer system/server 12 generatesthe second image 730 by removing the upper defect covered by the mask724.

Finally, the computer system/server 12 determines that the second image730 does not include any defect, and identifies or segments the defectby comparing the first image 710 with the second image 730. The defectsegmentation result is shown in the image 740, which shows the twosegmented defects. In this way, the multiple defects in the image can beprecisely segmented.

The present invention may be a system, a method, and/or a computerprogram product at any possible technical detail level of integration.The computer program product may include a computer readable storagemedium (or media) having computer readable program instructions thereonfor causing a processor to carry out aspects of the present invention.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present invention may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, configuration data for integrated circuitry, oreither source code or object code written in any combination of one ormore programming languages, including an object oriented programminglanguage such as Smalltalk, C++, or the like, and procedural programminglanguages, such as the “C” programming language or similar programminglanguages. The computer readable program instructions may executeentirely on the user's computer, partly on the user's computer, as astand-alone software package, partly on the user's computer and partlyon a remote computer or entirely on the remote computer or server. Inthe latter scenario, the remote computer may be connected to the user'scomputer through any type of network, including a local area network(LAN) or a wide area network (WAN), or the connection may be made to anexternal computer (for example, through the Internet using an InternetService Provider). In some embodiments, electronic circuitry including,for example, programmable logic circuitry, field-programmable gatearrays (FPGA), or programmable logic arrays (PLA) may execute thecomputer readable program instructions by utilizing state information ofthe computer readable program instructions to personalize the electroniccircuitry, in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a computer, or other programmable data processing apparatusto produce a machine, such that the instructions, which execute via theprocessor of the computer or other programmable data processingapparatus, create means for implementing the functions/acts specified inthe flowchart and/or block diagram block or blocks. These computerreadable program instructions may also be stored in a computer readablestorage medium that can direct a computer, a programmable dataprocessing apparatus, and/or other devices to function in a particularmanner, such that the computer readable storage medium havinginstructions stored therein comprises an article of manufactureincluding instructions which implement aspects of the function/actspecified in the flowchart and/or block diagram block or blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The flowchart and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof instructions, which comprises one or more executable instructions forimplementing the specified logical function(s). In some alternativeimplementations, the functions noted in the blocks may occur out of theorder noted in the Figures. For example, two blocks shown in successionmay, in fact, be accomplished as one step, executed concurrently,substantially concurrently, in a partially or wholly temporallyoverlapping manner, or the blocks may sometimes be executed in thereverse order, depending upon the functionality involved. It will alsobe noted that each block of the block diagrams and/or flowchartillustration, and combinations of blocks in the block diagrams and/orflowchart illustration, can be implemented by special purposehardware-based systems that perform the specified functions or acts orcarry out combinations of special purpose hardware and computerinstructions.

The descriptions of the various embodiments of the present inventionhave been presented for purposes of illustration, but are not intendedto be exhaustive or limited to the embodiments disclosed. Manymodifications and variations will be apparent to those of ordinary skillin the art without departing from the scope and spirit of the describedembodiments. The terminology used herein was chosen to best explain theprinciples of the embodiments, the practical application or technicalimprovement over technologies found in the marketplace, or to enableothers of ordinary skill in the art to understand the embodimentsdisclosed herein.

What is claimed is:
 1. A computer-implemented method for imageprocessing, comprising: determining, by one or more processors, whethera first image indicates a defect associated with a target object; inresponse to determining that the first image indicates the defect:generating, based on a heatmap, a mask covering a portion of the defect;and generating the second image by removing, from the first image, theportion of the defect; and identifying, by the one or more processors,the defect by comparing the first image with the second image.
 2. Thecomputer-implemented method of claim 1, wherein determining whether thefirst image indicates the defect comprises: applying, by the one or moreprocessors, the first image to an image classifier for classifying animage to be normal or abnormal; and in response to a result of theclassifying indicating that the first image is abnormal, determining, bythe one or more processors, that the first image indicates the defect.3. The computer-implemented method of claim 2, wherein the imageclassifier is a Binary Classifier model.
 4. The computer-implementedmethod of claim 1, wherein the heatmap indicates heat values of pixelsin the first image.
 5. The computer-implemented method of claim 1,further comprising generating the heatmap by applying the first image toa class activation heatmap model being trained to locate the defect inthe first image.
 6. The computer-implemented method of claim 1, whereingenerating the mask comprises: determining, by the one or moreprocessors, heat values of a set of pixels in the first image exceedinga predetermined threshold; and generating, by the one or moreprocessors, the mask covering the set of pixels.
 7. Thecomputer-implemented method of claim 1, wherein generating the secondimage comprises applying the first image with the mask to a GenerativeAdversarial Network (GAN) based model being trained to remove at leastthe portion of the defect.
 8. The computer-implemented method of claim1, wherein generating the second image comprises: obtaining, by the oneor more processors, an intermediate image by removing at least theportion of the defect from the first image; in response to the defectbeing absent from the intermediate image, determining, by the one ormore processors, the intermediate image to be the second image; and inresponse to a remaining portion of the defect being present in theintermediate image, removing, by the one or more processors, theremaining portion from the intermediate image based on a heatmap of theintermediate image to generate the second image.
 9. A device for imageprocessing, comprising: a processor; and a memory coupled to theprocessor and storing instructions thereon, the instructions, whenexecuted by the processor, performing acts including: determiningwhether a first image indicates a defect associated with a targetobject; in response to determining that the first image indicates thedefect: generating, based on a heatmap, a mask covering a portion of thedefect; and generating the second image by removing, from the firstimage, the portion of the defect; and identifying the defect bycomparing the first image with the second image.
 10. The device of claim9, wherein determining whether the first image indicates the defectcomprises: applying the first image to an image classifier forclassifying an image to be normal or abnormal; and in response to aresult of the classifying indicating that the first image is abnormal,determining that the first image includes the defect.
 11. The device ofclaim 10, wherein the image classifier is a Binary Classifier model. 12.The device of claim 9, wherein the heatmap indicates heat values ofpixels in the first image.
 13. The device of claim 9, wherein the actsfurther include generating the heatmap by applying the first image to aclass activation heatmap model being trained to locate the defect in thefirst image.
 14. The device of claim 9, wherein generating the maskcomprises: determining heat values of a set of pixels in the first imageexceeding a predetermined threshold; and generating the mask coveringthe set of pixels.
 15. The device of claim 9, wherein generating thesecond image comprises applying the first image with the mask to aGenerative Adversarial Network (GAN) based model being trained to removeat least the portion of the defect.
 16. The device of claim 9, whereingenerating the second image comprises: obtaining an intermediate imageby removing at least the portion of the defect from the first image; inresponse to the defect being absent from the intermediate image,determining the intermediate image to be the second image; and inresponse to a remaining portion of the defect being present in theintermediate image, removing the remaining portion from the intermediateimage based on a heatmap of the intermediate image to generate thesecond image.
 17. A computer program product, comprising anon-transitory computer readable storage medium having programinstructions embodied therewith, the program instructions executable bya processor to cause the processor to perform actions of: determiningwhether a first image indicates a defect associated with a targetobject; in response to determining that the first image indicates thedefect: generating, based on a heatmap, a mask covering a portion of thedefect; and generating the second image by removing, from the firstimage, the portion of the defect; and identifying the defect bycomparing the first image with the second image.
 18. The computerprogram product of claim 17, wherein determining whether the first imageindicates the defect comprises: applying the first image to an imageclassifier for classifying an image to be normal or abnormal; and inresponse to a result of the classifying indicating that the first imageis abnormal, determining that the first image includes the defect. 19.The computer program product of claim 17, wherein the heatmap indicatesheat values of pixels in the first image.
 20. The computer programproduct of claim 17, wherein generating the second image comprises:obtaining an intermediate image by removing at least the portion of thedefect from the first image; in response to the defect being absent fromthe intermediate image, determining the intermediate image to be thesecond image; and in response to a remaining portion of the defect beingpresent in the intermediate image, removing the remaining portion fromthe intermediate image based on a heatmap of the intermediate image togenerate the second image.